<script>
	function MessageCtrl($scope, CtrlUtil, $element, $http, modalService) {
		var ctrl = this
		this.onQuerySuccess = function(c) {
			return $http.post(':root/message/getReadState', {
				messageId : CtrlUtil.getIds(c.content)
			}).success(function(r) {
				CtrlUtil.addProperty(c.content, r, 'isRead')
			})
		}
		CtrlUtil.build(this, ':root/message/getMessages')

		this.markRead = function(item) {
			if (item.isRead) {
				return;
			}
			$http.post(':root/message/markRead', {
				messageId : item.id
			}).success(function(r) {
				item.isRead = 1
			})
		}
	}
</script>
<div ng-controller="MessageCtrl as ctrl" ng-init="ctrl.query()">
	<h3 class="header container-fluid media">消息通知</h3>
	<div class="container-fluid">
		<div class="well h4 ">
			<label>传递也是一种责任态度</label>
		</div>
	</div>

	<div class="container-fluid media">
		<table class="table  table-hover">
			<tr>
				<th>消息发送人</th>
				<th>时间</th>
				<th>内容</th>
				<th>状态</th>
			</tr>
			<tr ng-repeat="item in ctrl.entities.content">
				<td>{{item.fsr}}</td>
				<td>{{item.fssj |date:'yyyy-MM-dd HH:mm'}}</td>
				<td title="{{item.fsnr}}">{{item.fsnr}}</td>
				<td ng-click="ctrl.markRead(item)" ng-class="{'text-muted':item.isRead,'text-info':!item.isRead,'btn':!item.isRead}">{{item.isRead?'已读':'未读'}}</td>
			</tr>
		</table>
		<div class="panel-body">
			共有记录：
			<span>{{ctrl.entities.totalElements}}</span>
			条
			<div class="pull-right" ng-include="':root/components/page.html'"></div>
		</div>
	</div>
</div>
